<?php

namespace app\shop\controller;

use think\Request;
use think\Exception;
use think\Db;
use app\shop\model\ClientRegion as ClientRegionModel;

class ClientRegion extends \ShopController{

    //区域列表
    public function regionList(Request $request){
        $regionModel = new ClientRegionModel();
        try {
            $params = $request->get();
            $data = $regionModel->regionList($params);
            $this->successTerminate($data);
        } catch (Exception $e) {
            $this->serverErrorTerminate($e->getMessage());
        }
    }

    //添加区域
    public function add(Request $request){
        $regionModel = new ClientRegionModel();
        try {
            $params = $request->post();
            $data = $regionModel->add($params);
            $this->successTerminate($data);
        } catch (Exception $e) {
            $this->serverErrorTerminate($e->getMessage());
        }
    }

    //区域重命名
    public function rename(Request $request){
        $regionModel = new ClientRegionModel();
        try {
            $params = $request->post();
            $data = $regionModel->rename($params);
            $this->successTerminate($data);
        } catch (Exception $e) {
            $this->serverErrorTerminate($e->getMessage());
        }
    }

    //删除区域
    public function del_region($id){
        $regionModel = new ClientRegionModel();
        try {
            $data = $regionModel->del_region($id);
            $this->successTerminate($data);
        } catch (Exception $e) {
            $this->serverErrorTerminate($e->getMessage());
        }
    }

}